﻿using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ShopBack.Web.App_Start
{
    public class MyExcepTionFilter : FilterAttribute, IExceptionFilter
    {
        private static Logger logger = LogManager.GetCurrentClassLogger();
        public void OnException(ExceptionContext filterContext)
        {
            //错误信息
            string message = filterContext.Exception.Message;
            //用户名
            string userName = filterContext.HttpContext.User.Identity.Name;
            //控制器
            string contollerName = filterContext.RouteData.Values["Controller"].ToString();
            //动作方法
            string actionName = filterContext.RouteData.Values["Action"].ToString();

            logger.Error(message);
        
        }
    }
}